/*
 *The code is written by 51jiecai.com.
 *All rights reserved.
 */
package creational.design.patterns.singleton;

import java.lang.reflect.Constructor;

/**
 * 
 * @author forgkan Created on 2015年5月6日
 * 
 */
public class ReflectionSingletonTest {

	public static void main(String[] args) {

		EagerInitializationSingleton instanceOne = EagerInitializationSingleton
				.getInstance();

		EagerInitializationSingleton instanceTwo = null;
		try {
			Constructor[] constructors = EagerInitializationSingleton.class.getDeclaredConstructors();
			for (Constructor constructor : constructors) {
				// Below code will destroy the singleton pattern
				constructor.setAccessible(true);
				instanceTwo = (EagerInitializationSingleton) constructor.newInstance();
				break;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println(instanceOne.hashCode());
		System.out.println(instanceTwo.hashCode());
		
	}

}
